package ch.ms.persistenttimers;

import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.engine.camera.Camera;
import org.anddev.andengine.engine.options.EngineOptions;
import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.scene.background.ColorBackground;
import org.anddev.andengine.ui.activity.BaseGameActivity;

import ch.ms.persistenttimers.actions.MockupCounterTickAction;

import android.view.Display;

/*
 * Copyright 2011 dunhill

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */

public class TestActivity extends BaseGameActivity {
	
	@Override
	public Engine onLoadEngine() {
		//Create a camera with the current display resolution and add it to the DependencyManager
		final Display display = getWindowManager().getDefaultDisplay();
		Camera camera = new Camera(0, 0, display.getWidth(), display.getHeight());
		//create an engine and add it to the DependencyManager
		Engine engine = new Engine(new EngineOptions(true, ScreenOrientation.PORTRAIT, new RatioResolutionPolicy(camera.getWidth(), camera.getHeight()), camera));
		
		return engine;
	}
	
	@Override
	public void onLoadResources() {
		//Load all resources
	}

	@Override
	public Scene onLoadScene() {
		@SuppressWarnings("deprecation")
		final Scene scene = new Scene(1);
        scene.setBackground(new ColorBackground(0, 0, 0.8784f));
		
		return scene;
	}

	@Override
	public void onLoadComplete() {
		PersistentTimerManager man = new PersistentTimerManager(getEngine(), getApplicationContext());
		PersistentTimer timer = man.createNewTickingTimer(5.0f, 50, true);
		timer.addTickAction(new MockupCounterTickAction());
		timer.doStart();
	}
	
	@Override
	public void onResumeGame() {
		super.onResumeGame();
	}
}